//
// Created by hunan on 25-7-13.
//

#ifndef DOWNLOAD_TASK_H
#define DOWNLOAD_TASK_H

#include <string>
#include <memory>
#include "download_file_operate.h"

class DownloadNetOperate;
class ProtocolConnection;
class Loop;
class TimerTask;
class DownloadTask
{
public:
    DownloadTask();
    void Download(const std::string & url, const std::string & filename, int number);
private:
    void HeadFileDataSize();
    void CreateFileData(uint64_t data_size);
    void ReadyForDownload();
    void DownloadFile();
    void PrintStatistic() const;
private:
    std::string m_url{};
    std::string m_filename{};
    std::string m_etag;
    Loop * m_loop{nullptr};
    std::shared_ptr<DownloadNetOperate>  m_net_operate;
    std::shared_ptr<DownloadFileOperate> m_file_operate;
    std::shared_ptr<TimerTask>  m_statistic_timer;
};



#endif //DOWNLOAD_TASK_H
